package com.example.user_service.dao.dt;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

public class FindUserById {
    public String findUserById(String name, String pawd, String tyle) {
        return new SQL(){{
            SELECT("*");
            FROM("user_login");
            if(tyle.equals("tel")){
                WHERE("tel = #{param1} and paswd = #{param2}");
            } else if(tyle.equals("email")){
                WHERE("email = #{param1} and paswd = #{param2}");
            }else {
                WHERE("account = #{param1} and paswd = #{param2}");
            }
            //从这个toString可以看出，其内部使用高效的StringBuilder实现SQL拼接
        }}.toString();
    }
}
